import socket

if __name__ == '__main__':
    ip_local = ("127.0.0.1", 8000)
    sk = socket.socket()
    sk.bind(ip_local)
    sk.listen(5)  # 该网站仅能监听5个client 一旦超过会无法处理请求
    while True:
        print('server is running')
        connect, address = sk.accept()
        data = connect.recv(1024)
        try:
            print(data.decode('utf-8'))
        except:
            print(data)
        connect.send(b"HTTP/1.1 200 OK\r\nContent-Type:text/html;charset=utf-8\r\nConnection:Keep-Alive\r\n\r\n")
        connect.send("<html><head><title>测试使用</title><head><body><h1>仅供测试</h1></body></html>".encode('utf-8'))
        connect.close()
